class ScorePanel {
    score = 0 // 积分
    level = 1 //等级

    scoreEle: HTMLElement
    levelEle: HTMLElement

    maxLevel: number
    upScore: number


    constructor(maxLevel: number, upScore: number) {
        this.scoreEle = document.getElementById('score')!
        this.levelEle = document.getElementById('level')!
        this.maxLevel = maxLevel;
        this.upScore = upScore;
    }

    // 积分增加
    addScore() {
        this.scoreEle.innerHTML = ++this.score + ''
        if (this.score % this.upScore === 0) {
            this.levelUp()
        }
    }

    // 提升等级
    levelUp() {
        if (this.level < this.maxLevel) {
            this.levelEle.innerHTML = ++this.level + ''
        }
    }
}

export default ScorePanel